#include "qlistviewdialog.h"
#include "ui_qlistviewdialog.h"
#include "../../b-model/01-mail_model/qmailmodel.h"
QListViewDialog::QListViewDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::QListViewDialog)
{
    ui->setupUi(this);
    QStringList list;
    list << "a" << "b" << "c";
    //堆中创建的数据,在函数执行完毕之后就释放了,持有并使用这个对象的数据会有问题.
    // QMailModel model(li/*st);*/
    this->model = new QMailModel(list);
    ui->listView->setModel(this->model);
    ui->listView->show();
}

QListViewDialog::~QListViewDialog()
{
    delete ui;
}

void QListViewDialog::on_pushButton_clicked()
{

    int count = this->model->rowCount();
    QString str = QString::number(count);
    ui->lb_count->setText(str);
}


void QListViewDialog::on_pushButton_2_clicked()
{
    int pos = this->model->rowCount() - 1;
    this->model->insertRows(pos,2);
}


void QListViewDialog::on_pushButton_3_clicked()
{
    this->model->removeRows(0,1);
}

